//
//  KCTabBarVC.m
//  Jade
//
//  Created by king on 16/4/7.
//  Copyright © 2016年 KC. All rights reserved.
//

#import "KCTabBarVC.h"

@interface KCTabBarVC ()

@end

@implementation KCTabBarVC

@synthesize JadeTabBar;

#pragma mark - LifeCycle

- (void)viewDidLoad {
    [super viewDidLoad];
    [self createTabBarVC];
}

#pragma mark - Setup

- (void)createTabBarVC{
    
    NSArray *titleArray   = @[@"取金",@"订阅",@"我的"];
    NSArray *normalArray  = @[@"icon_home_tab",@"icon_subscibe_tab",@"icon_personal_tab"];
    NSArray *selectArray  = @[@"icon_home_tab_pressed",@"icon_subscibe_tab_pressed",@"icon_personal_tab_pressed"];
    NSArray *vcArray      = @[@"KCHomePageVC",@"KCTopicVC",@"KCMeVC"];

    [vcArray enumerateObjectsUsingBlock:^(id  _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
        Class class = NSClassFromString(obj);
        if (class) {
            UIViewController *vc = class.new;
            KCNavigationVC *navi = [[KCNavigationVC alloc]initWithRootViewController:vc];
            vc.tabBarItem.image = [UIImage imageNamed:normalArray[idx]];
            UIImage *selImage = [UIImage imageNamed:selectArray[idx]];
            vc.tabBarItem.selectedImage = selImage;
            vc.tabBarItem.title = titleArray[idx];
            [self addChildViewController:navi];
        }
        
    }];
    
    WEAK_SELF;
    //通知
    [[NOTIFICATION_CENTER rac_addObserverForName:@"typeThree" object:nil]subscribeNext:^(id x) {
        weakSelf.selectedIndex = 2;
    }];

    //通知
    [[NOTIFICATION_CENTER rac_addObserverForName:@"todayAuction" object:nil]subscribeNext:^(id x) {
        weakSelf.selectedIndex = 1;
    }];
    
    
    //获取手机安装的app
//    Class c = NSClassFromString(@"LSApplicationWorkspace");
//    id s = [(id)c performSelector:NSSelectorFromString(@"defaultWorkspace")];
//    NSArray *array = [s performSelector:NSSelectorFromString(@"allInstalledApplications")];
//
//    for (id item in array) {
//        
//        KCLog(@"---- %@",[item performSelector:NSSelectorFromString(@"applicationIdentifier")]);
//        KCLog(@"==== %@",[item performSelector:NSSelectorFromString(@"bundleVersion")]);
//        KCLog(@"-=-= %@",[item performSelector:NSSelectorFromString(@"shortVersionString")]);
//        
//    }
    
}



@end
